package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class StrategyDetail extends BaseDomain{

    public static final Integer STATE_RELEASE = 0; //发布
    public static final Integer STATE_TEMP = 1; //草稿

    private String title;

    private Date createTime;

    private Date releaseTime;

    private Integer sequence;

    private String coverUrl;

    private Integer state = STATE_TEMP;

    private StrategyCatalog catalog;

    private StrategyContent strategyContent;

    public String getStateName(){
        String msg = "草稿";
        if(state == STATE_RELEASE){
            msg = "发布";
        }
        return msg;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("sequence",sequence);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if(catalog != null){
            map.put("catalogId",catalog.getId());
            map.put("strategyId",catalog.getStrategyId());
        }
        return JSONUtil.toJSONString(map);
    }
}